// 基础类型
export * from './base';

// 业务实体类型
export * from './tenant';
export * from './organization';
export * from './user';
export * from './role';
export * from './department';
export * from './subscription';
export * from './config';

// 应用类型
export * from './navigation';

// 组件属性类型
export interface TableColumn<T = any> {
  key: string;
  title: string;
  dataIndex?: keyof T;
  width?: number | string;
  minWidth?: number;
  maxWidth?: number;
  align?: 'left' | 'center' | 'right';
  sortable?: boolean;
  filterable?: boolean;
  searchable?: boolean;
  render?: (value: any, record: T, index: number) => React.ReactNode;
  fixed?: 'left' | 'right';
  ellipsis?: boolean;
  hidden?: boolean;
  resizable?: boolean;
}

export interface FormField {
  name: string;
  label: string;
  type: 'text' | 'email' | 'password' | 'number' | 'select' | 'multiSelect' | 'date' | 'datetime' | 'textarea' | 'switch' | 'checkbox' | 'radio' | 'file' | 'custom';
  placeholder?: string;
  required?: boolean;
  disabled?: boolean;
  readonly?: boolean;
  hidden?: boolean;
  options?: { label: string; value: any }[];
  validation?: {
    pattern?: RegExp;
    min?: number;
    max?: number;
    minLength?: number;
    maxLength?: number;
    custom?: (value: any) => string | undefined;
  };
  helpText?: string;
  adornment?: {
    start?: React.ReactNode;
    end?: React.ReactNode;
  };
  dependencies?: string[]; // 依赖的其他字段
  renderIf?: (values: any) => boolean; // 条件渲染
  render?: (field: FormField, value: any, onChange: (value: any) => void) => React.ReactNode;
}

export interface DialogProps {
  open: boolean;
  title: string;
  content?: React.ReactNode;
  maxWidth?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
  fullWidth?: boolean;
  fullScreen?: boolean;
  onClose: () => void;
  onConfirm?: () => void;
  onCancel?: () => void;
  confirmText?: string;
  cancelText?: string;
  loading?: boolean;
  disabled?: boolean;
  showActions?: boolean;
}

export interface ConfirmDialogProps {
  open: boolean;
  title: string;
  message: string;
  onConfirm: () => void;
  onCancel: () => void;
  confirmText?: string;
  cancelText?: string;
  severity?: 'info' | 'warning' | 'error' | 'success';
}

export interface PageHeaderProps {
  title: string;
  subtitle?: string;
  breadcrumbs?: BreadcrumbItem[];
  actions?: React.ReactNode;
  extra?: React.ReactNode;
  avatar?: string;
  backUrl?: string;
}

export interface EmptyStateProps {
  title: string;
  description?: string;
  image?: string;
  action?: {
    label: string;
    onClick: () => void;
  };
}

export interface LoadingStateProps {
  loading: boolean;
  children: React.ReactNode;
  skeleton?: React.ReactNode;
  overlay?: boolean;
  size?: 'small' | 'medium' | 'large';
  text?: string;
}

// 钩子函数类型
export interface UseTableOptions<T> {
  data?: T[];
  loading?: boolean;
  pagination?: {
    page: number;
    pageSize: number;
    total: number;
  };
  selection?: {
    enabled: boolean;
    selectedRowKeys: string[];
    onSelectionChange: (selectedRowKeys: string[], selectedRows: T[]) => void;
  };
  sorting?: {
    field?: string;
    order?: 'asc' | 'desc';
    onSortChange: (field: string, order: 'asc' | 'desc') => void;
  };
  filtering?: {
    filters: Record<string, any>;
    onFilterChange: (filters: Record<string, any>) => void;
  };
}

export interface UseFormOptions<T> {
  initialValues?: Partial<T>;
  validationSchema?: any;
  onSubmit: (values: T) => Promise<void> | void;
  onError?: (error: any) => void;
  enableReinitialize?: boolean;
}

// 错误类型
export interface AppError {
  code: string;
  message: string;
  details?: any;
  timestamp: string;
  path?: string;
}